﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MemberInfoList.ascx.cs" Inherits="MemberInfoList" %>
<table>
<tr>
<td  valign="top" style=" padding-top: 0px">
<asp:DropDownList ID="DropDownList_Dpt" runat="server" DataSourceID="ObjectDataSource_Dpt" DataTextField="Name" OnLoad="DropDownList_Dpt_Load" AutoPostBack="True" OnSelectedIndexChanged="DropDownList_Dpt_SelectedIndexChanged" DataValueField="Id" OnDataBound="DropDownList_Dpt_DataBound" >
</asp:DropDownList><br />
<asp:ObjectDataSource ID="ObjectDataSource_Dpt" runat="server" SelectMethod="GetDepartments"
    TypeName="DepartmentDb"></asp:ObjectDataSource>
    <br />

<asp:GridView ID="GridView_Staff" runat="server" DataSourceID="ObjectDataSource_StaffInfo" DataKeyNames="Id" OnDataBinding="GridView_Staff_DataBinding" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView_Staff_SelectedIndexChanged" OnRowUpdating="GridView_Staff_RowUpdating" EmptyDataText="n/a" OnDataBound="GridView_Staff_DataBound" OnRowDataBound="GridView_Staff_RowDataBound" AllowPaging="True" AllowSorting="True">
    <Columns>
        <asp:BoundField DataField="Id" HeaderText="编号" ReadOnly="True" />
        <asp:BoundField DataField="SerialNumber" HeaderText="考核编号" ReadOnly="True" />
        <asp:BoundField DataField="Name" HeaderText="姓名" />
        <asp:TemplateField HeaderText="部门">
            <ItemTemplate>
                <%# GetDptNameById(Eval("DepartmentNum"))%>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList ID="DropDownList_StaffDpt" runat="server" DataSourceID="ObjectDataSource_Dpt"
                    DataTextField="Name" DataValueField="Id" OnDataBound="DropDownList_StaffDpt_DataBound">
                </asp:DropDownList>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="级别">
            <ItemTemplate>
                <%# Eval("Level") %>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server" 
                DataSource = '<%# getLevels() %>' OnDataBound="DropDownList1_DataBound">
                
                </asp:DropDownList>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="类别" Visible="False">
            <EditItemTemplate>
                &nbsp;<asp:DropDownList ID="DropDownList4" runat="server" DataSource="<%# StaffDB.PositionNames %>">
                </asp:DropDownList>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# GetPositionName(Eval("Position")) %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Title" HeaderText="职务" />
        <asp:BoundField DataField="Evaluator" HeaderText="考核人" />
        <asp:BoundField DataField="Verifier" HeaderText="审核人" />
        <asp:CommandField ShowEditButton="True" EditText ="修改"
         ShowDeleteButton = "True"/>
    </Columns>
    <FooterStyle CssClass="FooterStyle" />
    <RowStyle CssClass="RowStyle" />
    <EmptyDataRowStyle CssClass="EmptyRowStyle" />
    <PagerStyle CssClass="PagerStyle" />
    <SelectedRowStyle CssClass="SelectedRowStyle" />
    <HeaderStyle CssClass="HeaderStyle" />
    <EditRowStyle CssClass="EditRowStyle" />
    <AlternatingRowStyle CssClass="AltRowStyle" />
</asp:GridView>

<asp:ObjectDataSource ID="ObjectDataSource_StaffInfo" runat="server" DataObjectTypeName="StaffDetail" SelectMethod="GetStaffs" TypeName="StaffDB" UpdateMethod="UpdateStaffInfo" DeleteMethod="DeleteStaff" InsertMethod="InsertStaff" OnSelecting="ObjectDataSource_StaffInfo_Selecting">
    <SelectParameters>
        <asp:Parameter DefaultValue="0" Name="DepartmentNum" />
    </SelectParameters>
</asp:ObjectDataSource>
    <br />
<asp:DetailsView ID="DetailsView_Staff" runat="server" DataSourceID="ObjectDataSource_StaffInfo"
    Height="20px" Width="125px" AutoGenerateRows="False" OnItemInserting="DetailsView_Staff_ItemInserting" OnItemCommand="DetailsView_Staff_ItemCommand" OnItemInserted="DetailsView_Staff_ItemInserted" EmptyDataText="n/a">
    <Fields>
        <asp:CommandField ShowInsertButton="True" />
        <asp:BoundField DataField="SerialNumber" HeaderText="编号" Visible="False" />
        <asp:BoundField DataField="Name" HeaderText="姓名" Visible="False" />
        <asp:TemplateField HeaderText="部门" Visible="False">
            <InsertItemTemplate>
                <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="ObjectDataSource_Dpt"
                    DataTextField="Name" DataValueField="Id" OnDataBound="DropDownList2_DataBound">
                </asp:DropDownList>
            </InsertItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="级别" Visible="False">
            <InsertItemTemplate>
                <asp:DropDownList ID="DropDownList3" runat="server" DataSource = '<%# getLevels() %>'>
                </asp:DropDownList>
            </InsertItemTemplate>
        </asp:TemplateField>
    </Fields>
</asp:DetailsView>
</td></tr>
</table>